﻿#include "Note.h"
#include <array>

constexpr std::array<const char*, NOTE_LEVEL_COUNT> gNoteLevelMap{
	"调试",
	"提示",
	"警告",
	"错误",
	"危险",
};

Note::Note(const QString& msg, NOTE_LEVEL level, QWidget* parent)
	: 
	BaseDlg(parent, gNoteLevelMap[level])
{
	ui.setupUi(&this->content_view);
	this->base_ui.content->addWidget(&this->content_view);
	ui.lab_note_msg->setText(msg);
	ui.widget_debug->setVisible(NOTE_LEVEL_DEBUG == level);
	ui.widget_info->setVisible(NOTE_LEVEL_INFO == level);
	ui.widget_wran->setVisible(NOTE_LEVEL_WRAN == level);
	ui.widget_error->setVisible(NOTE_LEVEL_ERROR == level);
	ui.widget_critical->setVisible(NOTE_LEVEL_CRITICAL == level);
}

Note::~Note()
{
}

bool Note::Debug(const QString& msg)
{
	Note nt{ msg,NOTE_LEVEL_DEBUG };
	return nt.showDialog();
}

bool Note::Info(const QString& msg)
{
	Note nt{ msg,NOTE_LEVEL_INFO };
	return nt.showDialog();
}

bool Note::Warn(const QString& msg)
{
	Note nt{ msg,NOTE_LEVEL_WRAN };
	return nt.showDialog();
}

bool Note::Error(const QString& msg)
{
	Note nt{ msg,NOTE_LEVEL_ERROR };
	return nt.showDialog();
}

bool Note::Critical(const QString& msg)
{
	Note nt{ msg,NOTE_LEVEL_CRITICAL };
	return nt.showDialog();
}
